package com.bit.book.model;

import com.bit.book.enmus.ResultStatus;
import lombok.Data;
import org.springframework.web.bind.annotation.RequestMapping;

@Data
public class Result <T>{
    private ResultStatus status;
    private String errMsg;
    private T data;
    /**
     * 业务执行成功返回的方法
     *
     * @param data
     * @return
     */
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result();
        result.setData(data);
        result.setStatus(ResultStatus.SUCCESS);
        result.setErrMsg("");
        return result;
    }

    /**
     *
     * 业务执行失败
     *
     * @param
     * @return
     */
    public static Result fail(String errMsg) {
        Result result = new Result();
        result.setStatus(ResultStatus.FATL);
        result.setErrMsg(errMsg);
        result.setData("");
        return result;

    }
    /**
     *业务执行失败
     * @param
     * @return
     */
    public static Result unLogin() {
        Result result = new Result();
        result.setStatus(ResultStatus.UNLOGIN);
        result.setErrMsg("用户未登录");
        result.setData(null);
        return result;
    }


}
